//
//  SearchProductsModel.swift
//  LoveFreshBeen
//
//  Created by 维尼的小熊 on 16/1/12.
//  Copyright © 2016年 tianzhongtao. All rights reserved.
//  GitHub地址:https://github.com/ZhongTaoTian/LoveFreshBeen
//  Blog讲解地址:http://www.jianshu.com/p/879f58fe3542
//  小熊的新浪微博:http://weibo.com/5622363113/profile?topnav=1&wvr=6

import UIKit

class SearchProducts: NSObject {
    var code: Int = -1
    var msg: String?
    var reqid: String?
    var data: [Goods]?
    
    class func loadSearchData(_ completion:((_ data: SearchProducts?, _ error: NSError?) -> Void)) {
        
        
        guard let path = Bundle.main.path(forResource: "促销", ofType: nil) else{
            return
        }
        
        let url = URL(fileURLWithPath: path)
        
        guard let jsonString = try? String(contentsOf: url) else{
            return
        }
        
        let searchProducts = SearchProducts.yy_model(withJSON: jsonString)
        
        if searchProducts != nil {
            completion(searchProducts, nil)
        }
    }
        
    
    // 返回容器类中的所需要存放的数据类型 (以 Class 或 Class Name 的形式)。
    class func modelContainerPropertyGenericClass() -> [AnyHashable: Any] {
        return ["data": Goods.self]
    }
}
